/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#include "StdAfx.h"
#include "EthernetCounters.h"

//---------------------------------------------------------------------------

EthernetCounters::EthernetCounters(void)
{
	Initialize();
}

EthernetCounters::~EthernetCounters(void)
{
}

//---------------------------------------------------------------------------

void EthernetCounters::Initialize(void)
{
	cntARP       = 0;

	cntTCPv4     = 0;
	cntUDPv4     = 0;
	cntICMPv4    = 0;
	cntIPv4Other = 0;

	cntTCPv6     = 0;
	cntUDPv6     = 0;
	cntICMPv6    = 0;
	cntIPv6Other = 0;

	cntEthOther  = 0;
}

//---------------------------------------------------------------------------

void EthernetCounters::LoadFromPointer(EthernetCounters* ecIn)
{
	cntARP       = ecIn->cntARP;

	cntTCPv4     = ecIn->cntTCPv4;
	cntUDPv4     = ecIn->cntUDPv4;
	cntICMPv4    = ecIn->cntICMPv4;
	cntIPv4Other = ecIn->cntIPv4Other;

	cntTCPv6     = ecIn->cntTCPv6;
	cntUDPv6     = ecIn->cntUDPv6;
	cntICMPv6    = ecIn->cntICMPv6;
	cntIPv6Other = ecIn->cntIPv6Other;

	cntEthOther  = ecIn->cntEthOther;
}

//---------------------------------------------------------------------------

bool EthernetCounters::IsEmpty(void)
{
	if(cntARP       != 0) return false;

	if(cntTCPv4     != 0) return false;
	if(cntUDPv4     != 0) return false;
	if(cntICMPv4    != 0) return false;
	if(cntIPv4Other != 0) return false;

	if(cntTCPv6     != 0) return false;
	if(cntUDPv6     != 0) return false;
	if(cntICMPv6    != 0) return false;
	if(cntIPv6Other != 0) return false;

	if(cntEthOther  != 0) return false;

	return true;
}

//---------------------------------------------------------------------------

DWORD EthernetCounters::GetTotalCount(void)
{
	DWORD res;

	res  = cntARP;

	res += cntTCPv4;
	res += cntUDPv4;
	res += cntICMPv4;
	res += cntIPv4Other;

	res += cntTCPv6;
	res += cntUDPv6;
	res += cntICMPv6;
	res += cntIPv6Other;

	res += cntEthOther;

	return res;
}

//---------------------------------------------------------------------------
